<!DOCTYPE html>
<html >

	<head>
		<meta charset="utf-8">
		<title>体检登录</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/mui.css">
		<link rel="stylesheet" href="css/app.css">
        <link rel="stylesheet" href="css/weui.css">
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <script type="text/javascript" src="js/jquery-2.0.0.min.js"></script>
        <script type="text/javascript" src="js/utile.js"></script>
        <script type="text/javascript" src="js/bootstrap.min.js"></script>
        <script type="text/javascript">
$(document).ready(function(){
// 	jump();
  $(".username").mousedown(function(){
    $(this).css({"border":"1px solid #30a5ff","background":"url(image/me2.png) 8px no-repeat"});
  });
   $(".username").mouseout(function(){
    $(this).css({"border":"1px solid #c9c9c9","background":"url(image/me.png) 8px no-repeat"});
  });
    $(".userkey").mousedown(function(){
    $(this).css({"border":"1px solid #30a5ff","background":"url(image/key2.png) 5px no-repeat"});
  });
   $(".userkey").mouseout(function(){
    $(this).css({"border":"1px solid #c9c9c9","background":"url(image/key.png) 5px no-repeat"});
  });
});

	function jump(){
		  var url = getURL() + "/mobile/toJump";
		  var pram = {};
		  $.ajax({
			  type: 'POST',
			  url: url,
			  data: pram,
			  success: function(data){
					switch (data.jumpNum) {
					case "1":
						window.location.href = "preview.html";
						break;
					case "2":
						window.location.href = "before.html";
						break;
					case "3":
						window.location.href = "order.html";
						break;
					}
			  },
			  dataType: "json"
			});
	}
	var cardInfo;
	function login(){  
		if(!$('.username').val()) {
			alert("请填写账号/卡号");
			return false;
		}
		if(!$('.userkey').val()) {
			alert("请填写密码");
			return false;
		}
		  var username =  $(".username").val();
		  var password =  $(".userkey").val();
		  var url = getURL() + "/mobile/login";
		  var pram = {username: username, password: password };
		  $.ajax({
			  type: 'POST',
			  url: url,
			  data: pram,
			  success: function(data){
// 				  window.location.href = "before.html";
				if(data.result == 0) {
					alert("卡号或密码输入有误,请重新输入");
				}
				if(data.result == 1) {
					if(data.cardList && data.cardList.length>1){
						$(".supp").empty();
					  	var str = '<tr><td width="65%">卡号</td><td width="35%">项目名称</td></tr>';
						$(".supp").append(str);
						for(var i=0;i<data.cardList.length;i++){
							  var supp = data.cardList[i];
							  var str = '<tr><td width="65%"><a onclick="choose('+ supp.cardNum +')" class="">'+supp.cardNum+'</a></td><td width="35%">'+supp.projectName+'</td></tr>';
							  $(".supp").append(str);
						  }
						$('#myModal').modal();
						return;
					}
					cardInfo = data.card;
					sessionStorage.setItem("isFamilyRes", data.card.isFamilyRes);
					sessionStorage.setItem("isDwnldRpt", data.card.isDwnldRpt);
					window.location.href = "menu.html";
// 					jump();
				}
				if(data.result == 2) {
					alert("卡号或密码输入有误,请重新输入!");
				}
			  },
			  dataType: "json"
			});
	}  
	
	function choose(cardNum){
		$('#myModal').modal('hide');
		  var url = getURL() + "/mobile/choose?cardNum="+cardNum;
		  var pram = {username: username, password: password };
		  $.ajax({
			  type: 'get',
			  url: url,
			  success: function(data){
//				  window.location.href = "before.html";
				if(data.result == 0) {
					alert("卡号或密码输入有误,请重新输入!");
				}
				if(data.result == 1) {
					cardInfo = data.card;
					sessionStorage.setItem("isFamilyRes", data.card.isFamilyRes);
					sessionStorage.setItem("isDwnldRpt", data.card.isDwnldRpt);
					window.location.href = "menu.html";
				}
				if(data.result == 2) {
					alert("卡号或密码输入有误,请重新输入!");
				}
			  },
			  dataType: "json"
			});
	}
	   
</script>
	</head>

	<body >

		<header id="header" class="mui-bar mui-bar-nav" >
			
			<h1 class="mui-title">体检预约</h1>
		</header>

		<div class="container loginTop" style="width:80%;">
        
        <div>
        <input id="username" name="username" type="text"  placeholder="登录账号/卡号" class="username">
        
         <input id="password" name="" type="password" placeholder="请输入密码"  class="userkey" >
     
        </div>
       <div class="pt30"> 
       
         <a class="weui_btn weui_btn_plain_blue" style="font-size:16px;" onclick="login()">登录</a></div>
         <div class="callTit">
         <p > 客服热线(TEL)  :  4000-609-891    </p>
         <p> 客服服务时间(WORKTIME) :  工作日 08:00-18:00    </p>
         </div>
		</div>
	

	</body>
	<div class="modal fade " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	    <div class="modal-dialog" role="document">
	        <div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
	                        aria-hidden="true">&times;</span></button>
	                <h6 class="modal-title" style="color: gray" id="myModalLabel">你有多个卡号，请选择一个登录 </h6>
	            </div>
	            <div class="modal-body" style="overflow :scroll;">
	            	<table width="100%" border="0" class="baseTable supp">
	            </div>
	        </div>
	    </div>
	</div>

</html>